<?php
namespace Admin\Controller;
use Think\Controller;
class loginController extends Controller {
    public function index(){
        $this->display();
    }
    public function checkData()
    {
    	$password = md5(I('post.password'));
    	$res = array(
    		'nickname'=>I('post.nickname'),
    		'password'=>$password
    		);
    	$sql = M('user')->where($res)->find();
    	
    		if ($sql) {
    			if ($sql['is_admin']==1) {
    				$_SESSION['id']=$sql['id'];
		    		$arr = array(
		                'error' => 0,
		                'info' => '登陆成功'
		                );
		            echo json_encode($arr);
		            exit;
		        }else{
		        	$arr = array(
	                'error' => 1,
	                'info' => '无权限登陆'
	                );
	            echo json_encode($arr);
		        }
    		}else{
	             $arr = array(
	                'error' => 1,
	                'info' => '昵称或者密码错误'
	                );
	            echo json_encode($arr);
	        }
    	
    	
    	}
    
}